#!/usr/bin/python3
import sys

## (k + 1) * i + k * (k + 1) / 2 = n => i=[2 * n / (k+1) - k]/2
try:
    t = int(input())
    if t < 1 or t > 1000:
        sys.exit(0)
    ids = 0
    while t > 0:
        n = int(input())
        if n < 1 or n > 10 ** 9:
            sys.exit(0)
        t = t - 1
        ids = ids + 1
        if n == 1 or n == 2 or n & n-1 == 0:
            print(f"Case #{ids}: 0")
            continue
        x = 0
        y = 1
        c = 0
        while n >= (y + 2) * (y + 1) / 2:
            if 2 * n % (y + 1) == 0:
                temp = 2 * n / (y + 1) - y
                if temp > 0 and temp % 2 == 0 and temp / 2 != 0:
                    c = c + 1
            y = y + 1
        print(f"Case #{ids}: {c}")

except ValueError:
    pass
except EOFError:
    pass
except MemoryError:
    pass
